package com.zhyl.demo.service.impl;

import com.zhyl.demo.entity.TheEnd;
import com.zhyl.demo.mapper.TheEndMapper;
import com.zhyl.demo.service.TheEndService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;

/**
 * @author yang3
 */
@Service
public class TheEndServiceImpl implements TheEndService {
    private final TheEndMapper theEndMapper;
    @Autowired
    private TheEndServiceImpl(TheEndMapper theEndMapper)
    {
        this.theEndMapper = theEndMapper;
    }

    @Override
    public Boolean addTheEnd(TheEnd theEnd) {
        Integer integer = theEndMapper.addTheEnd(theEnd);
        if (integer>0){
            return true;
        }else {
            return null;
        }
    }

    @Override
    public ArrayList<TheEnd> getAll() {
        ArrayList<TheEnd> all = theEndMapper.getAll();
        if (all!=null){
            return all;
        }else {
            return null;
        }
    }

    @Override
    public ArrayList<TheEnd> getByDoc(int docId) {
        ArrayList<TheEnd> byDoc = theEndMapper.getByDoc(docId);
        if (byDoc!=null){
            return byDoc;
        }else {
            return null;
        }
    }

    @Override
    public ArrayList<TheEnd> getByPatient(int patientId) {
        ArrayList<TheEnd> byPatient = theEndMapper.getByPatient(patientId);
        if (byPatient!=null){
            return byPatient;
        }else {
            return null;
        }
    }

    @Override
    public ArrayList<TheEnd> searchPatient(Integer patientId, int docId) {
        ArrayList<TheEnd> theEnds = theEndMapper.searchPatient(patientId, docId);
        if (theEnds!=null)
        {
            return theEnds;
        }else {
            return null;
        }
    }

    @Override
    public Integer checkHasPay(Integer patientId) {
        if (patientId<=0){
            return -1;
        }
        Integer integer;
        integer = theEndMapper.checkHasPay(patientId);
        return integer;
    }

    @Override
    public TheEnd checkCaseHistoryByAppointment(int appointmentId) {
        TheEnd theEnd = theEndMapper.checkCaseHistoryByAppointment(appointmentId);
        return theEnd;
    }

    @Override
    public TheEnd getTheEndDetail(int theEndId) {
        if (theEndId<=0){
            return null;
        }
        return theEndMapper.getTheEndDetail(theEndId);
    }

    @Override
    public ArrayList<TheEnd> adminSearchPatient(Integer patId) {
        return theEndMapper.adminSearchPatient(patId);
    }

    @Override
    public Boolean updateInfo(TheEnd theEndDetail) {
        Integer integer = theEndMapper.updateInfo(theEndDetail);
        if (integer>0){
            return true;
        }else {
            return null;
        }
    }

    @Override
    public ArrayList<TheEnd> searchPatientIlls(int patId, int docId) {
        ArrayList<TheEnd> theEnds = theEndMapper.searchPatientIlls(patId, docId);
        if (theEnds!=null)
        {
            return theEnds;
        }else {
            return null;
        }
    }


}
